package actions;

import java.util.ArrayList;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.UniversityModel;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import forms.ApplicantForm;
import forms.DegreeForm;

public class InputAddressAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ArrayList<DegreeForm> degrees = new ArrayList<DegreeForm>();
		request.getSession().setAttribute("degrees", degrees);
		ApplicantForm citizenshipForm = (ApplicantForm) request.getSession()
				.getAttribute("citizenshipForm");
		if ("United States".equals(citizenshipForm.getCitizenship())) {
			Vector<String> locations = UniversityModel.getAllLocation();
			request.setAttribute("locations", locations);
			return mapping.findForward("us");
		} else {
			return mapping.findForward("nonus");
		}
	}
}